package cn.yqn.fallback;

import cn.yqn.feign.MovieFeignService;
import cn.yqn.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MovieFeignServiceFallbackFatory implements FallbackFactory<MovieFeignService> {
    @Override
    public MovieFeignService create(Throwable throwable) {
        return new MovieFeignService() {
            @Override
            public JsonResult list() {
                return JsonResult.error("服务不可用，请稍后重试", "500");
            }

            @Override
            public JsonResult buy(Long userId, Long movieId) {
                return JsonResult.error("服务不可用，请稍后重试", "500");
            }

            @Override
            public JsonResult watch(Long userId, Long movieId) {
                return JsonResult.error("服务不可用，请稍后重试", "500");
            }
        };
    }
}
